package javabase.biji;

import org.junit.Test;

/**
 * @Auther: luzhanshi
 * @Date: 2021/2/1 - 02 - 01 - 10:43 
 * @Description: javabase.biji
 * @version: 1.0
 */
public class _19继承 {
    @Test
    public void test(){
        Child child = new Child("Tom");
        System.out.println(child.name);
        System.out.println(child.age);
        child.lastName="孙子";
        System.out.println(child.lastName);
        child.method();
    }
    
    public class Child extends Parent{
        public Child(String name) {
            super(name);
        }

    }
    public class Parent extends GrandDad{
        String name;
        int age;

        public Parent() {
            System.out.println("父类无参构造方法执行了。。。");
        }
        public Parent(String name) {
            this.name=name;
            System.out.println("父类有参构造方法执行了。。。");
        }
    }
    
    public class GrandDad{
        String lastName="爷爷";
        public void method(){
            System.out.println("爷爷的方法执行了。。。");
        }
    }
    
}
